package com.work.keep.activity;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.work.keep.R;
import com.work.keep.adapter.MyFollowsRecyclerAdapter;
import com.work.keep.adapter.MyRecyclerAdapter;
import com.work.keep.base.BaseActivity;
import com.work.keep.datas.DynamicDiscoverData;

import java.util.List;


/**
 * Created by dllo on 16/1/21.
 */
public class HotDynamicActivitiy extends BaseActivity implements View.OnClickListener {
    private RecyclerView recyclerView;
    private MyFollowsRecyclerAdapter myRecyclerAdapter;
    static List<DynamicDiscoverData.DataEntity> discoverDatas;
    private GridLayoutManager gridLayoutManager;
    private ImageView actionLastBtn;

    public static void goToHotDynamicActivity(Context context, List<DynamicDiscoverData.DataEntity> discoverDatas) {
        Intent intent = new Intent(context, HotDynamicActivitiy.class);
        HotDynamicActivitiy.discoverDatas = discoverDatas;
        Log.d("aaaaaa", discoverDatas.get(0).getContent());
        context.startActivity(intent);
    }

    @Override
    protected View getLayoutView() {
        return null;
    }

    @Override
    protected int getLayout() {
        return R.layout.activity_hot_dynamic;
    }

    @Override
    protected void initView() {
        actionLastBtn = (ImageView) findViewById(R.id.actionLastBtn);
        recyclerView = (RecyclerView) findViewById(R.id.hotDyanmicRecycler);
    }

    @Override
    protected void initData() {
        gridLayoutManager = new GridLayoutManager(this, 2);
        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                if (position % 3 == 0) {
                    return 2;
                }
                return 1;
            }
        });
        myRecyclerAdapter = new MyFollowsRecyclerAdapter(this, discoverDatas);
        recyclerView.setLayoutManager(gridLayoutManager);
        recyclerView.setAdapter(myRecyclerAdapter);
        myRecyclerAdapter.setOnRecyclerItemClickListener(new OnRecyclerItemClickListener() {
            @Override
            public void onItemClick(int position) {
//                PeopleActivity.goToPeopleActivity(HotDynamicActivitiy.this);
                DynamicDetailsActivity.goToDynamicDetailActivity(HotDynamicActivitiy.this, discoverDatas.get(position).get_id());
            }
        });
        actionLastBtn.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        finish();
    }
}
